激活虚拟环境后找不到模块熊猫

时间:2020-08-17 21:08:35

标签: python pandas windows pip virtualenv

即使激活了虚拟环境,我的python脚本也无法导入pandas模块。

这是我采取的步骤。首先,我创建了一个名为jpx_env的虚拟环境并将其激活,然后安装了requirements.txt

中列出的所有必要软件包。
py -m pip install --user virtualenv
py -m venv jpx_env
.\jpx_env\Scripts\activate
pip install -r requirements.txt

然后,重新执行.py脚本

python __main__.py

但是,出现此错误。

(jpx_env) c:\jpx>python __main__.py
Traceback (most recent call last):
  File "__main__.py", line 3, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

PC为Windows10 Pro(64位)。 我认为有两种可能性。

  1. virtualenv未激活。 但是我在(jpx_env)之前看到c:\jpx,所以我相信它已被激活...

  2. pandas软件包未正确下载。 当我运行pip install -r requirements.txt时,会收到一堆错误消息和警告。 pyzmq 似乎有问题,但不确定是否是引起问题的原因。这是来自控制台的摘录(实际消息太长了,无法在此处粘贴)。


Collecting pandas==0.23.4
   Downloading pandas-0.23.4.tar.gz (10.5 MB)
Using legacy setup.py install for pandas, since package 'wheel' is not installed.
Running setup.py install for pyzmq ... error
   ERROR: Command errored out with exit status 1:
Warning: Couldn't find an acceptable libzmq on the system.

If you expected pyzmq to link against an installed libzmq, please check to make sure:

    * You have a C compiler installed
    * A development version of Python is installed (including headers)
    * A development version of ZMQ >= 3.2 is installed (including headers)
    * If ZMQ is not in a default location, supply the argument --zmq=<path>
    * If you did recently install ZMQ to a default location,
      try rebuilding the ld cache with `sudo ldconfig`
      or specify zmq's location with `--zmq=/usr/local`

You can skip all this detection/waiting nonsense if you know
you want pyzmq to bundle libzmq as an extension by passing:

    `--zmq=bundled`

I will now try to build libzmq as a Python extension
unless you interrupt me (^C) in the next 10 seconds...

************************************************
 1...
Using bundled libzmq
already have bundled\zeromq
staging platform.hpp from: C:\Users\hirano\AppData\Local\Temp\pip-install-6f7rwzt9\pyzmq\buildutils\include_win32
************************************************
************************************************
building 'zmq.libzmq' extension
error: Microsoft Visual C++ 14.0 is required. 
Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 
'c:\jpx\jpx_env\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = 
'"'"'C:\\Users\\hirano\\AppData\\Local\\Temp\\pip-install-6f7rwzt9\\pyzmq\\setup.py'"'"';
 __file__='"'"'C:\\Users\\hirano\\AppData\\Local\\Temp\\pip-install-
6f7rwzt9\\pyzmq\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)
(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code,
 __file__, '"'"'exec'"'"'))' install --record 'C:\Users\hirano\AppData\Local\Temp\
pip-record-ptocij7r\install-record.txt' --single-version-externally-managed 
--compile --install-headers 'c:\jpx\jpx_env\include\site\python3.8\pyzmq' 
Check the logs for full command output.

0 个答案:

没有答案