pythonpath

using pip to install packages locally in spite of satisfied global requirements

早过忘川 提交于 2019-12-07 04:24:52
问题 I am trying to use pip to install a package locally in ~/.local . The problem is that the package (in an older version) is already available globally on the system. Even though the global python packages directory is not in my PYTHONPATH , pip still refuses to install, thinking that the package requirement is satisfied. This is similar to the issue described here, except I am not using sudo so the solution does not apply: pip - Requirement already satisfied? If I do: pip install --user numpy

Changing PYTHONPATH in shell [closed]

喜你入骨 提交于 2019-12-07 03:58:37
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I'm a completely new user to Python and shell scripts, and have run into a dead end with this, even after Googling the issue and banging my head against

pylint import and dynamic path modification

穿精又带淫゛_ 提交于 2019-12-06 17:29:24
My projects are generally structured like this: projectname/ __init__.py python/ mymodule.py other_stuff/ more_stuff/ where __init__.py contains the following code import os mypath = os.path.dirname(os.path.realpath(os.path.abspath(__file__))) __path__ = [mypath, mypath+"/python"] This "skips" the python directory when importing to allow python code in the form from projectname import mymodule rather than from projectname.python import mymodule . This appears to break pylint however, being unable to import any modules in the project despite $PYTHONPATH being set correctly. Creating a softlink

scrapy cannot import module while it's in my pythonpath

浪子不回头ぞ 提交于 2019-12-06 15:57:46
I had a functional scrapy project, and then I decided to clean it. In order to do so, I got my database module out of the scrapy part of my project and I can't include it anymore. Now the project looks like this : myProject/ database/ __init__.py model.py databaseFactory.py myScrapy/ __init__.py settings.py myScrapy/ __init__.py pipeline.py spiders/ spiderA.py spiderB.py api/ __init__.py config/ __init__.py (only files related to my question are displayed) I want to use the databaseFactory in scrapy. I have added to my .bashrc the following lines : PYTHONPATH=$PYTHONPATH:my/path/to/my/project

Python sees `json` module but pipenv doesn't. Why?

纵然是瞬间 提交于 2019-12-06 15:11:42
I am trying to help a coworker configure their VM. I am having a very strange problem: Z:\codebase>pipenv uninstall Locking [dev-packages] dependencies. Locking [packages] dependencies. nv\\resolver.py", line 3, in <module> import json ModuleNotFoundError: No module named 'json' Z:\codebase>python Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import json >>> json <module 'json' from 'C:\\Program Files\\Python35\\lib\\json\\__init__.py'> >>> So python can import json when

Automatically call common initialization code without creating __init__.py file

♀尐吖头ヾ 提交于 2019-12-06 05:26:15
问题 I have two directories in my project: project/ src/ scripts/ "src" contains my polished code, and "scripts" contains one-off Python scripts. I would like all the scripts to have "../src" added to their sys.path, so that they can access the modules under the "src" tree. One way to do this is to write a scripts/__init__.py file, with the contents: scripts/__init__.py: import sys sys.path.append("../src") This works, but has the unwanted side-effect of putting all of my scripts in a package

What should be my python packages path for a user install on MacOS?

妖精的绣舞 提交于 2019-12-06 04:58:20
问题 I'm on Mac OS X and I've heard that to avoid global installation of packages (using sudo) that might cause problems with the python files that OS X uses, the path to install python packages must be different than that of OS X. Currently python executables are installed in : /usr/local/bin/ Pip installs modules over here : /usr/local/lib/python2.7/site-packages Python is used from here : /usr/local/bin/python Are these paths safe? 回答1: If you are on OS X, you should also have Python in /usr

Split Python source into separate directories?

独自空忆成欢 提交于 2019-12-06 04:14:17
问题 Here are some various Python packages my company "foo.com" uses: com.foo.bar.web com.foo.bar.lib com.foo.zig.web com.foo.zig.lib com.foo.zig.lib.lib1 com.foo.zig.lib.lib2 Here's the traditional way to store the source on disk: pysrc/ com/ foo/ bar/ web/ lib/ zig/ web/ lib/ lib1/ lib2/ PYTHONPATH=pysrc But for organizational purposes (different teams, different revision control, etc.), we want to store these as follows: bar/ pysrc/ com/ foo/ bar/ web/ lib/ zig/ pysrc/ com/ foo/ zig/ web/ lib/

Django Management Command ImportError

China☆狼群 提交于 2019-12-06 04:05:02
问题 I have problem with imported module into my qsl/management/commands/<customcommand>.py file. in fact, my app structure is : qsl/management/commands/ : dir for my management commands qsl/management/jobs/ : dir for my mangement jobs jobs are python classes that contains the job i want to be done in the coresponding command e.g: news command in qsl/management/commands/ imports news job in qsl/management/jobs/ my error when i want to execute python manage.py news is an importerror : no module

Why does virtualenv inherit $PYTHONPATH from my shell?

末鹿安然 提交于 2019-12-06 01:41:34
问题 So I'm migrating all my tools from python2 to python3.4 on an Ubuntu 14.04 machine. So far I've done the following: aliased python to python3 in my zshrc for just my user installed pip3 on the system itself (but I'll just be using virtualenvs for everything anyway so I won't really use it) changed my virtualenvwrapper "make" alias to mkvirtualenv --python=/usr/bin/python3 ('workon' is invoked below as 'v') Now curiously, and you can clearly see it below, running python3 from a virtualenv