[英]Is this a Python path issue?
我對我的 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
任何人都可以指出我正確的方向嗎?
首先你需要升級你的 pip 安裝程序:
pip3 install --upgrade setuptools pip
安裝包后:
pip3 install browser-cookie3
並使用python3執行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.