pythonpath

Bad Interpreter: No such file or directory error when launching iPython with Anaconda

…衆ロ難τιáo~ 提交于 2019-12-24 12:44:30
问题 My ipython was working fine until I installed a new IDE and accidentally changed some path settings. Now, when I try to launch ipython from terminal I get: -bash: /Users/JohnSmith/anaconda/bin/ipython: /Users/JohnSmith/anaconda/python.app/Contents/MacOS/python: bad interpreter: No such file or directory How do I change my path/local environment settings back so that it works? 回答1: It seems that uninstalling and re-installing Anaconda was the easiest solution (after several hours of playing

PATH issues with homebrew-installed Python 2 and Python 3 on OSX

一世执手 提交于 2019-12-24 09:44:44
问题 I'm relatively new to programming and have searched 'til my fingertips were blue, but can't seem to find a solution to the problem I'm having. I have homebrew-installed versions of Python 2 and Python 3 on OSX and I can't seem to get the proper PATH/PYTHONPATH in my .bash_profile in order to be able to import modules properly in both versions in IDLE. I can, however, import modules when running Python 2 or Python 3 directly in a shell window. I am launching IDLE via terminal so it should

Python - How to PYTHONPATH with a complex directory structure?

谁说我不能喝 提交于 2019-12-24 06:12:58
问题 Consider the following file\directory structure: project\ | django_project\ | | __init__.py | | django_app1\ | | | __init__.py | | | utils\ | | | | __init__.py | | | | bar1.py | | | | ... | | | ... | | django_app2\ | | | __init__.py | | | bar2.py | | | ... | | ... | scripts\ | | __init__.py | | foo.py | | ... How should I use sys.path.append in foo.py so that I could use bar1.py and bar2.py ? How would the import look like? 回答1: Using relative paths would be much more desirable for

What is the cleanest way to add a directory of third-party packages to the beginning of the Python path?

烈酒焚心 提交于 2019-12-24 00:56:19
问题 My context is appengine_config.py, but this is really a general Python question. Given that we've cloned a repo of an app that has an empty directory lib in it, and that we populate lib with packages by using the command pip install -r requirements.txt --target lib , then: dirname ='lib' dirpath = os.path.join(os.path.dirname(__file__), dirname) For importing purposes, we can add such a filesystem path to the beginning of the Python path in the following way (we use index 1 because the first

How to read the large number of text files from a Directory using Python

假如想象 提交于 2019-12-23 06:07:22
问题 I'm working on a project using Python(3.6) and Django(2) in which I need to read all the text files from a directory one by one, I have written the code but it is reading only 28 files from a folder which has 30 text files at the moment for testing purpose and return an error. From views.py: def get_txt_files(base_dir): for entry in os.scandir(base_dir): if entry.is_file() and entry.name.endswith(".txt"): # print(entry.path) yield entry.path, entry.name elif entry.is_dir(): yield from get_txt

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

萝らか妹 提交于 2019-12-23 03:54:07
问题 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

django project directory structure and the python path

情到浓时终转凉″ 提交于 2019-12-20 09:25:31
问题 I am trying to get the best possible set up for developing my django project from the start and I'm having trouble getting everything to play nicely in the directory structure. I have set up virtualenv's (env in this example) so that I can deploy a clean empty python environment for every django project. The basic structure is as follows: /env/ /bin /db <--- Django DB /downloads /lib /static <--- Where css/imgs/js etc is served from /project/ <--- Django root /__init__.py /settings.py /manage

Deploying Django on OS 10.9 Server

拜拜、爱过 提交于 2019-12-20 03:58:06
问题 I have a project that uses Django that I'm attempting to deploy on a local network on a machine running OS X Server (10.9). I can run it locally with the project's manage.py script and have all of the dependencies and everything, but am struggling to get it running as a regular website through Server.app. Below are the configuration files for the project required by web applications on the server, all pointing to the actual code in : /Library/Server/Web/Data/WebApps/project/.../ (it's not

Force import module from Python standard library instead of PYTHONPATH default

人走茶凉 提交于 2019-12-18 19:01:49
问题 I have a custom module in one of the directories in my PYTHONPATH with the same name as one of the standard library modules, so that when I import module_name , that module gets loaded. If I want to use the original standard library module, is there any way to force Python to import from the standard library rather than from the PYTHONPATH directory, short of renaming the custom module and changing every reference to point to the new name? 回答1: The ideal solution would be to rename your

Python 2.x multiple version issues regarding PYTHONPATH

不想你离开。 提交于 2019-12-18 17:00:02
问题 There's Python 2.6 installed in the system. Now I want to use modules introduced in Python 2.7. Because I have no root privilege, I have built & installed 2.7 under my home directory ($HOME/local/) I added the following to my $HOME/.bashrc: export PATH=$HOME/local/bin:$PATH export PYTHONPATH=$HOME/local/lib/python2.7:$PYTHONPATH Now I encountered the two problems I want ask for workarounds. 1. Invoking Python 2.7 Newly installed Python 2.7 doesn't find 2.6 modules in system's library path (