我不知道我的Python路径是否设置正确。我在企业环境中使用Ubuntu,所以我一直在virtualenv
环境中安装带有--user
设置的包/模块(我没有管理员或sudo
权限)。
(my_env)xx@xx:~/environments$ pip install --user browsercookie
Requirement already satisfied (use --upgrade to upgrade): browsercookie in /home/myUsername/.local/lib/python2.7/site-packages
但是当我运行我的文件时,我得到:
ImportError: No module named browsercookie
其他详细信息:
(my_env)xx@xx:~/environments$ which python
/usr/share/anaconda/bin/python
这是我在安装browsercookie
时收到的消息
(my_env)xx@xx:~/environments$ python <where setup files are>/setup.py install --user
/usr/share/anaconda/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running install
running build
running build_py
package init file './__init__.py' not found (or not a regular file)
copying ./my_file.py -> build/lib/browsercookie
package init file './__init__.py' not found (or not a regular file)
running install_lib
copying build/lib/browsercookie/my_file.py -> /home/myUsername/.local/lib/python2.7/site-packages/browsercookie
byte-compiling /home/myUsername/.local/lib/python2.7/site-packages/browsercookie/my_file.py to my_file.pyc
running install_egg_info
Writing /home/myUsername/.local/lib/python2.7/site-packages/browsercookie-0.7.1-py2.7.egg-info
还有..。
(my_env)xx@xx:~/environments$ which pip
/usr/share/anaconda/bin/pip
(my_env)xx@xx:~/environments$ pip install browsercookie
Requirement already satisfied (use --upgrade to upgrade): browsercookie in /home/myUsername/.local/lib/python2.7/site-packages
新环境详细信息:
xx@xx:~/environments$ virtualenv new_env
New python executable in new_env/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
xx@xx:~/environments$ source new_env/bin/activate
(new_env)xx@xx:~/environments$ which virtualenv
/usr/bin/virtualenv
(new_env)xx@xx:~/environments$ which pip
/home/username/environments/new_env/bin/pip
(new_env)xx@xx:~/environments$ which python
/home/username/environments/new_env/bin/python
有谁能给我指个方向吗?
发布于 2021-02-24 16:43:55
首先,您需要升级pip安装程序:
pip3 install --upgrade setuptools pip
安装程序包后:
pip3 install browser-cookie3
并使用python3执行
https://stackoverflow.com/questions/46147876
复制相似问题