Can't install pandas (and numpy) in virtual environment

Question:

So, recently I decided to try using venv for my new django project. I’m following some tutorials, but now I’m facing a problem – I can’t install Pandas package. I installed django via Windows PowerShall without problems, but after I tried to install pandas with that command
(.vkr) PS C:django> python -m pip install pandas
I get this:

Collecting pandas
  Using cached pandas-1.5.2.tar.gz (5.2 MB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [269 lines of output]
      Collecting setuptools>=51.0.0
        Using cached setuptools-65.6.3-py3-none-any.whl (1.2 MB)
      Collecting wheel
        Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
      Collecting Cython<3,>=0.29.32
        Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
      Collecting oldest-supported-numpy>=2022.8.16
        Using cached oldest_supported_numpy-2022.11.19-py3-none-any.whl (4.9 kB)
      Collecting numpy==1.19.3
        Using cached numpy-1.19.3.zip (7.3 MB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error

        Preparing metadata (pyproject.toml) did not run successfully.
        exit code: 1

        [236 lines of output]
        Running from numpy source directory.
        setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
          run_build = parse_setuppy_commands()
        Processing numpy/random_bounded_integers.pxd.in
        Processing numpy/randombit_generator.pyx
        Processing numpy/randommtrand.pyx
        Processing numpy/random_bounded_integers.pyx.in
        Processing numpy/random_common.pyx
        Processing numpy/random_generator.pyx
        Processing numpy/random_mt19937.pyx
        Processing numpy/random_pcg64.pyx
        Processing numpy/random_philox.pyx
        Processing numpy/random_sfc64.pyx
        Cythonizing sources
        blas_opt_info:
        blas_mkl_info:
        customize Mingw32CCompiler
          libraries mkl_rt not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        blis_info:
          libraries blis not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        openblas_info:
          libraries openblas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        atlas_3_10_blas_threads_info:
        Setting PTATLAS=ATLAS
          libraries tatlas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        atlas_3_10_blas_info:
          libraries satlas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        atlas_blas_threads_info:
        Setting PTATLAS=ATLAS
          libraries ptf77blas,ptcblas,atlas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        atlas_blas_info:
          libraries f77blas,cblas,atlas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        accelerate_info:
          NOT AVAILABLE

        C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilssystem_info.py:1914: UserWarning:
            Optimized (vendor) Blas libraries are not found.
            Falls back to netlib Blas library which has worse performance.
            A better performance should be easily gained by switching
            Blas library.
          if self._calc_info(blas):
        blas_info:
          libraries blas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilssystem_info.py:1914: UserWarning:
            Blas (http://www.netlib.org/blas/) libraries not found.
            Directories to search for the libraries can be specified in the
            numpy/distutils/site.cfg file (section [blas]) or by setting
            the BLAS environment variable.
          if self._calc_info(blas):
        blas_src_info:
          NOT AVAILABLE

        C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilssystem_info.py:1914: UserWarning:
            Blas (http://www.netlib.org/blas/) sources not found.
            Directories to search for the sources can be specified in the
            numpy/distutils/site.cfg file (section [blas_src]) or by setting
            the BLAS_SRC environment variable.
          if self._calc_info(blas):
          NOT AVAILABLE

        non-existing path in 'numpy\distutils': 'site.cfg'
        lapack_opt_info:
        lapack_mkl_info:
          libraries mkl_rt not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        openblas_lapack_info:
          libraries openblas not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        openblas_clapack_info:
          libraries openblas,lapack not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        flame_info:
          libraries flame not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        atlas_3_10_threads_info:
        Setting PTATLAS=ATLAS
          libraries lapack_atlas not found in C:django.vkrlib
          libraries tatlas,tatlas not found in C:django.vkrlib
          libraries lapack_atlas not found in C:
          libraries tatlas,tatlas not found in C:
        <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
          NOT AVAILABLE

        atlas_3_10_info:
          libraries lapack_atlas not found in C:django.vkrlib
          libraries satlas,satlas not found in C:django.vkrlib
          libraries lapack_atlas not found in C:
          libraries satlas,satlas not found in C:
        <class 'numpy.distutils.system_info.atlas_3_10_info'>
          NOT AVAILABLE

        atlas_threads_info:
        Setting PTATLAS=ATLAS
          libraries lapack_atlas not found in C:django.vkrlib
          libraries ptf77blas,ptcblas,atlas not found in C:django.vkrlib
          libraries lapack_atlas not found in C:
          libraries ptf77blas,ptcblas,atlas not found in C:
        <class 'numpy.distutils.system_info.atlas_threads_info'>
          NOT AVAILABLE

        atlas_info:
          libraries lapack_atlas not found in C:django.vkrlib
          libraries f77blas,cblas,atlas not found in C:django.vkrlib
          libraries lapack_atlas not found in C:
          libraries f77blas,cblas,atlas not found in C:
        <class 'numpy.distutils.system_info.atlas_info'>
          NOT AVAILABLE

        lapack_info:
          libraries lapack not found in ['C:\django\.vkr\lib', 'C:\']
          NOT AVAILABLE

        C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilssystem_info.py:1748: UserWarning:
            Lapack (http://www.netlib.org/lapack/) libraries not found.
            Directories to search for the libraries can be specified in the
            numpy/distutils/site.cfg file (section [lapack]) or by setting
            the LAPACK environment variable.
          return getattr(self, '_calc_info_{}'.format(name))()
        lapack_src_info:
          NOT AVAILABLE

        C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilssystem_info.py:1748: UserWarning:
            Lapack (http://www.netlib.org/lapack/) sources not found.
            Directories to search for the sources can be specified in the
            numpy/distutils/site.cfg file (section [lapack_src]) or by setting
            the LAPACK_SRC environment variable.
          return getattr(self, '_calc_info_{}'.format(name))()
          NOT AVAILABLE

        numpy_linalg_lapack_lite:
          FOUND:
            language = c
            define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]

        C:msys64mingw64libpython3.9distutilsdist.py:274: UserWarning: Unknown distribution option: 'define_macros'
          warnings.warn(msg)
        running dist_info
        running build_src
        build_src
        building py_modules sources
        creating build
        creating buildsrc.mingw_x86_64-3.9
        creating buildsrc.mingw_x86_64-3.9numpy
        creating buildsrc.mingw_x86_64-3.9numpydistutils
        building library "npymath" sources
        Traceback (most recent call last):
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilsfcompilercompaq.py", line 78, in CompaqVisualFCompiler
            m.initialize()
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilsmsvccompiler.py", line 48, in initialize
            _MSVCCompiler.initialize(self)
          File "C:msys64mingw64libpython3.9distutilsmsvccompiler.py", line 259, in initialize
            self.__paths = self.get_msvc_paths("path")
          File "C:msys64mingw64libpython3.9distutilsmsvccompiler.py", line 602, in get_msvc_paths
            r"Win32 (%s)Directories" % (self.__root, platform))
        AttributeError: 'MSVCCompiler' object has no attribute '_MSVCCompiler__root'

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 351, in <module>
            main()
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 333, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 152, in prepare_metadata_for_build_wheel
            return hook(metadata_directory, config_settings)
          File "C:UsersZenBookAppDataLocalTemppip-build-env-2iw3wr9ooverlaylibpython3.9site-packagessetuptoolsbuild_meta.py", line 157, in prepare_metadata_for_build_wheel
            self.run_setup()
          File "C:UsersZenBookAppDataLocalTemppip-build-env-2iw3wr9ooverlaylibpython3.9site-packagessetuptoolsbuild_meta.py", line 248, in run_setup
            super(_BuildMetaLegacyBackend,
          File "C:UsersZenBookAppDataLocalTemppip-build-env-2iw3wr9ooverlaylibpython3.9site-packagessetuptoolsbuild_meta.py", line 142, in run_setup
            exec(compile(code, __file__, 'exec'), locals())
          File "setup.py", line 508, in <module>
            setup_package()
          File "setup.py", line 500, in setup_package
            setup(**metadata)
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscore.py", line 169, in setup
            return old_setup(**new_attr)
          File "C:UsersZenBookAppDataLocalTemppip-build-env-2iw3wr9ooverlaylibpython3.9site-packagessetuptools__init__.py", line 165, in setup
            return distutils.core.setup(**attrs)
          File "C:msys64mingw64libpython3.9distutilscore.py", line 148, in setup
            dist.run_commands()
          File "C:msys64mingw64libpython3.9distutilsdist.py", line 966, in run_commands
            self.run_command(cmd)
          File "C:msys64mingw64libpython3.9distutilsdist.py", line 985, in run_command
            cmd_obj.run()
          File "C:UsersZenBookAppDataLocalTemppip-build-env-2iw3wr9ooverlaylibpython3.9site-packagessetuptoolscommanddist_info.py", line 31, in run
            egg_info.run()
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscommandegg_info.py", line 24, in run
            self.run_command("build_src")
          File "C:msys64mingw64libpython3.9distutilscmd.py", line 313, in run_command
            self.distribution.run_command(command)
          File "C:msys64mingw64libpython3.9distutilsdist.py", line 985, in run_command
            cmd_obj.run()
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscommandbuild_src.py", line 144, in run
            self.build_sources()
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscommandbuild_src.py", line 155, in build_sources
            self.build_library_sources(*libname_info)
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscommandbuild_src.py", line 288, in build_library_sources
            sources = self.generate_sources(sources, (lib_name, build_info))
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscommandbuild_src.py", line 378, in generate_sources
            source = func(extension, build_dir)
            st = config_cmd.try_link('int main(void) { return 0;}')
          File "C:msys64mingw64libpython3.9distutilscommandconfig.py", line 241, in try_link
            self._check_compiler()
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilscommandconfig.py", line 80, in _check_compiler
            self.fcompiler = new_fcompiler(compiler=self.fcompiler,
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilsfcompiler__init__.py", line 876, in new_fcompiler
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilsfcompiler__init__.py", line 777, in load_all_fcompiler_classes
            __import__ (module_name)
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilsfcompilercompaq.py", line 54, in <module>
            class CompaqVisualFCompiler(FCompiler):
          File "C:UsersZenBookAppDataLocalTemppip-install-umn76yiznumpy_f76fed0aa6fd429dbfd840b2dced598cnumpydistutilsfcompilercompaq.py", line 83, in CompaqVisualFCompiler
            if '_MSVCCompiler__root' in str(msg):
        NameError: name 'msg' is not defined
        [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed

      Encountered error while generating package metadata.

      See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Installing via IDE (PyCharm) failed too. I guess I lack some package(s). After searching for similar questions (they were mostly for Mac and Ubantu) I tried to install numpy. It failed too with error "Failed building wheel for numpy" (I’m not posting all text unless necessary because its really long). From the text above I guess I need mkl_rt, blis and something, but I really don’t know what to install, I don’t remember facing this kind of problem when I was installing pandas globaly (it works fine).
I upgraded pip, I have python v. 3.9 so I really don’t know what to do next. UPD. Installed setuptools. Now I have another problem.

Collecting pandas
  Using cached pandas-1.5.2.tar.gz (5.2 MB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [71 lines of output]
      Collecting setuptools>=51.0.0
        Using cached setuptools-65.6.3-py3-none-any.whl (1.2 MB)
      Collecting wheel
        Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
      Collecting Cython<3,>=0.29.32
        Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
      Collecting oldest-supported-numpy>=2022.8.16
        Using cached oldest_supported_numpy-2022.11.19-py3-none-any.whl (4.9 kB)
      Collecting numpy==1.19.3
        Using cached numpy-1.19.3.zip (7.3 MB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'error'
        error: subprocess-exited-with-error

        Getting requirements to build wheel did not run successfully.
        exit code: 1

        [40 lines of output]
        Traceback (most recent call last):
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 351, in <module>
            main()
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 333, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 112, in get_requires_for_build_wheel
            backend = _build_backend()
          File "C:django.vkrlibpython3.9site-packagespip_vendorpep517in_process_in_process.py", line 77, in _build_backend
            obj = import_module(mod_path)
          File "C:msys64mingw64libpython3.9importlib__init__.py", line 127, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
          File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
          File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
          File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
          File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
          File "<frozen importlib._bootstrap_external>", line 850, in exec_module
          File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
          File "C:UsersZenBookAppDataLocalTemppip-build-env-3fjiq_ztoverlaylibpython3.9site-packagessetuptools__init__.py", line 253, in <module>
            monkey.patch_all()
          File "C:UsersZenBookAppDataLocalTemppip-build-env-3fjiq_ztoverlaylibpython3.9site-packagessetuptoolsmonkey.py", line 101, in patch_all
            patch_for_msvc_specialized_compiler()
          File "C:UsersZenBookAppDataLocalTemppip-build-env-3fjiq_ztoverlaylibpython3.9site-packagessetuptoolsmonkey.py", line 164, in patch_for_msvc_specialized_compiler
            patch_func(*msvc9('find_vcvarsall'))
          File "C:UsersZenBookAppDataLocalTemppip-build-env-3fjiq_ztoverlaylibpython3.9site-packagessetuptoolsmonkey.py", line 151, in patch_params
            mod = import_module(mod_name)
          File "C:msys64mingw64libpython3.9importlib__init__.py", line 127, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
          File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
          File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
          File "<frozen importlib._bootstrap_external>", line 850, in exec_module
          File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
          File "C:UsersZenBookAppDataLocalTemppip-build-env-3fjiq_ztoverlaylibpython3.9site-packagessetuptools_distutilsmsvc9compiler.py", line 295, in <module>
            raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
        distutils.errors.DistutilsPlatformError: VC 6.0 is not supported by this module
        [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: subprocess-exited-with-error

      Getting requirements to build wheel did not run successfully.
      exit code: 1

      See above for output.

      note: This error originates from a subprocess, and is likely not a problem with pip.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Asked By: Ksenia

||

Answers:

One thing that always works for me is to run command prompt as an administrator. If you’re on windows, just press the windows key, search "command prompt", and select to "run it as an administrator". Try running your command then.

It might not be the fix for your problem, but it always seems to work for me.

I hope this helps!

Answered By: Alpha Wolf Studios

I reinstalled phyton, checked my PATHs. Then I created virtual environment through PyCharm (before I created it via command prompt) following YouTube video instructions and it resolved my problems.

Answered By: Ksenia
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.