I try to install a virtual environment from GitHub
first I made a virtual environment with Conda, then I install git in this environment. Next I cloned the project and cd to package package directory contains setup.py.
But when I try to install setup.py (pip install setup.py) I got an error:
Could not find suitable distribution for Requirement.parse('env_mltf.yml')
This is the output of my terminal:
running install
running bdist_egg
running egg_info
writing mltf.egg-info/PKG-INFO
/opt/anaconda3/envs/DL/lib/python3.9/site-packages/setuptools/dist.py:125: UserWarning: newlines not allowed and will break in the future
warnings.warn("newlines not allowed and will break in the future")
writing dependency_links to mltf.egg-info/dependency_links.txt
writing requirements to mltf.egg-info/requires.txt
writing top-level names to mltf.egg-info/top_level.txt
package init file './__init__.py' not found (or not a regular file)
reading manifest file 'mltf.egg-info/SOURCES.txt'
writing manifest file 'mltf.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.9-x86_64/egg
running install_lib
running build_py
creating build/bdist.macosx-10.9-x86_64/egg
creating build/bdist.macosx-10.9-x86_64/egg/gym_mltf
copying build/lib/gym_mltf/README.md -> build/bdist.macosx-10.9-x86_64/egg/gym_mltf
copying build/lib/gym_mltf/example.py -> build/bdist.macosx-10.9-x86_64/egg/gym_mltf
byte-compiling build/bdist.macosx-10.9-x86_64/egg/gym_mltf/example.py to example.cpython-39.pyc
creating build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying mltf.egg-info/PKG-INFO -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying mltf.egg-info/SOURCES.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying mltf.egg-info/dependency_links.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying mltf.egg-info/requires.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
copying mltf.egg-info/top_level.txt -> build/bdist.macosx-10.9-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/mltf-0.0.1-py3.9.egg' and adding 'build/bdist.macosx-10.9-x86_64/egg' to it
removing 'build/bdist.macosx-10.9-x86_64/egg' (and everything under it)
Processing mltf-0.0.1-py3.9.egg
Removing /opt/anaconda3/envs/DL/lib/python3.9/site-packages/mltf-0.0.1-py3.9.egg
Copying mltf-0.0.1-py3.9.egg to /opt/anaconda3/envs/DL/lib/python3.9/site-packages
mltf 0.0.1 is already the active version in easy-install.pth
Installed /opt/anaconda3/envs/DL/lib/python3.9/site-packages/mltf-0.0.1-py3.9.egg
Processing dependencies for mltf==0.0.1
Searching for env_mltf.yml
Reading https://pypi.org/simple/env_mltf.yml/
Reading https://pypi.org/simple/env-mltf.yml/
Couldn't find index page for 'env_mltf.yml' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for env_mltf.yml
error: Could not find suitable distribution for Requirement.parse('env_mltf.yml')
I created my own python package named jjnsegutils and upload it to Pypi website. But after I successfully install it by pip install jjnsegutils, I still can not import it. Error shows: ModuleNotFoundError: No module named 'jjnsegutils'.
Details about the whole procedure are as follows.
Package structure and details
The structure of my package is:
jjnsequtils
├─ __init__.py
├─ myutil
├─ __init__.py
├─ myutil.py
├─ LICENSE
├─ README.md
├─ setup.py
Two __init__.py files are empty.
In my setup.py:
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="jjnsegutils", # Replace with your own username
version="0.0.10",
author="Jingnan",
author_email="jiajingnan2222#gmail.com",
description="A package of common utilities for Medical images segmentation and evaluation.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/Ordgod/jjnsegutils",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
How do I generate the package?
I use command python setup.py sdist bdist_wheel to generate distribute files.
logging information:
running sdist
running egg_info
writing jjnsegutils.egg-info/PKG-INFO
writing dependency_links to jjnsegutils.egg-info/dependency_links.txt
writing top-level names to jjnsegutils.egg-info/top_level.txt
reading manifest file 'jjnsegutils.egg-info/SOURCES.txt'
writing manifest file 'jjnsegutils.egg-info/SOURCES.txt'
running check
creating jjnsegutils-0.0.10
creating jjnsegutils-0.0.10/jjnsegutils.egg-info
creating jjnsegutils-0.0.10/myutil
copying files to jjnsegutils-0.0.10...
copying README.md -> jjnsegutils-0.0.10
copying setup.py -> jjnsegutils-0.0.10
copying jjnsegutils.egg-info/PKG-INFO -> jjnsegutils-0.0.10/jjnsegutils.egg-info
copying jjnsegutils.egg-info/SOURCES.txt -> jjnsegutils-0.0.10/jjnsegutils.egg-info
copying jjnsegutils.egg-info/dependency_links.txt -> jjnsegutils-0.0.10/jjnsegutils.egg-info
copying jjnsegutils.egg-info/top_level.txt -> jjnsegutils-0.0.10/jjnsegutils.egg-info
copying myutil/__init__.py -> jjnsegutils-0.0.10/myutil
copying myutil/myutil.py -> jjnsegutils-0.0.10/myutil
Writing jjnsegutils-0.0.10/setup.cfg
Creating tar archive
removing 'jjnsegutils-0.0.10' (and everything under it)
running bdist_wheel
running build
running build_py
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
creating build/bdist.linux-x86_64/wheel
copying build/lib/myutil.py -> build/bdist.linux-x86_64/wheel
creating build/bdist.linux-x86_64/wheel/myutil
copying build/lib/myutil/__init__.py -> build/bdist.linux-x86_64/wheel/myutil
copying build/lib/myutil/myutil.py -> build/bdist.linux-x86_64/wheel/myutil
running install_egg_info
Copying jjnsegutils.egg-info to build/bdist.linux-x86_64/wheel/jjnsegutils-0.0.10-py3.7.egg-info
running install_scripts
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.linux-x86_64/wheel/jjnsegutils-0.0.10.dist-info/WHEEL
creating 'dist/jjnsegutils-0.0.10-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'myutil.py'
adding 'myutil/__init__.py'
adding 'myutil/myutil.py'
adding 'jjnsegutils-0.0.10.dist-info/LICENSE'
adding 'jjnsegutils-0.0.10.dist-info/METADATA'
adding 'jjnsegutils-0.0.10.dist-info/WHEEL'
adding 'jjnsegutils-0.0.10.dist-info/top_level.txt'
adding 'jjnsegutils-0.0.10.dist-info/RECORD'
removing build/bdist.linux-x86_64/wheel
How do I distribute the package?
I use command twine upload dist/* to upload the files in dist to Pypi.
How do I install the package?
I use command pip install jjnsegutils to install it into my own environment named py37 created by conda. It shows
Collecting jjnsegutils
Downloading jjnsegutils-0.0.10-py3-none-any.whl (11 kB)
Installing collected packages: jjnsegutils
Successfully installed jjnsegutils-0.0.10
Then I type $ python in my terminal to enter the python interractive terminal. and type:
>>> import jjnsegutils
But it shows:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'jjnsegutils'
What actions I have tried to diagnosize the issue?
I checked the package by command $ pip show jjnsegutils, it shows:
Name: jjnsegutils
Version: 0.0.10
Summary: A package of common utilities for Medical images segmentation and evaluation.
Home-page: https://github.com/Ordgod/jjnsegutils
Author: Jingnan
Author-email: jiajingnan2222#gmail.com
License: UNKNOWN
Location: /home/jjia/.conda/envs/py37/lib/python3.7/site-packages
Requires:
Required-by:
And I checked it futher by $ ls /home/jjia/.conda/envs/py37/lib/python3.7/site-packages, it shows:
... # other packages
jjnsegutils-0.0.10.dist-info
... # other packages
I thought there should be anotehr directory named jjnsegutils along with jjnsegutils-0.0.10.dist-info. But I did not see it. Is this the reason that I can not import my own package?
I make sure that the virtual environment is always the same one named py37 during the whole procedure. I used CentOS, python3.7.
Looking forward to any discussion and advice. Thanks very much!
You should import myutil.
packages is a list of all Python import packages that should be included in the Distribution Package. Instead of listing each package manually, we can use find_packages() to automatically discover all packages and subpackages. In this case, the list of packages will be example_pkg as that’s the only package present.
https://packaging.python.org/tutorials/packaging-projects/
I am developing using Python 3.7.
I'm trying to write a small Python package and install it into a virtual environment for testing. The library is structured like this:
my_package/
src/
my_package/
__init__.py
utilities.py
some_data_files/
setup.py
README.md
...
When I create virtual environment and try to install:
(env) C:\Users\path\to\my_package python setup.py install
The output is:
running install
running bdist_egg
running egg_info
writing my_package.egg-info\PKG-INFO
writing dependency_links to my_package.egg-info\dependency_links.txt
writing top-level names to my_package.egg-info\top_level.txt
reading manifest file 'my_package.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'my_package.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
warning: install_lib: 'build\lib' does not exist -- no Python modules to install
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\EGG-INFO
copying my_package.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying my_package.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying my_package.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying my_package.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist\my_package-0.0.1-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing my_package-0.0.1-py3.7.egg
Copying my_package-0.0.1-py3.7.egg to c:\users\jon\development\my_package_env\env\lib\site-p
ackages
Adding my_package 0.0.1 to easy-install.pth file
Installed c:\users\jon\development\my_package_env\env\lib\site-packages\my_package-0.0.1-py3
.7.egg
Processing dependencies for my_package==0.0.1
Finished processing dependencies for my_package==0.0.1
There is an egg file in site-packages but no directory containing any of the files from the my_package directory. This is my first time writing a Python package for distribution, and I'm using the Python documentation as a guide, but I'm not ready to upload anywhere and would like to test locally. Can someone let me know what steps I must take to be able to test my package locally in a virtual environment?
Create a source distribution and a built distribution of your project, with these commands:
(env) C:\Users\jon\development\my_package_env>python3 setup.py sdist
(env) C:\Users\jon\development\my_package_env>python3 setup.py bdist_wheel
Note the two newly created archives in the dist/ directory
Try to install these distributions in fresh virtual environments:
C:\Users\jon\development\my_package_env>python3 -m venv sdist-env
C:\Users\jon\development\my_package_env>sdist-env\Scripts\activate.bat
(sdist-env) C:\Users\jon\development\my_package_env>pip install dist\my_package-0.0.1.tar.gz
(sdist-env) C:\Users\jon\development\my_package_env>deactivate
C:\Users\jon\development\my_package_env>python3 -m venv wheel-env
C:\Users\jon\development\my_package_env>wheel-env\Scripts\activate.bat
(wheel-env) C:\Users\jon\development\my_package_env>pip install dist\my_package-0.0.1-py3-none-any.whl
Once you're confident with this, you might want to look at tox to automate the testing of your project in multiple virtual environments.
I'm new to Python and Django so forgive me if this question seems silly. I'm following the django tutorial and I'm stuck at the step when you use your own package
The app mysite works and there was no error.
I've setup all the required files according to the tutorial.
I've run python3 setup.py sdist (inside django-polls folder)
There's the file django-polls-0.1.tar.gz in django-polls/dist/
$ cd ..
$ pip3 install --user django-polls/dist/django-polls-0.1.tar.gz
Processing ./django-polls/dist/django-polls-0.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): django-polls==0.1 from file:///home/viet/webdev/django-polls/dist/django-polls-0.1.tar.gz in /home/viet/.local/lib/python3.6/site-packages
Building wheels for collected packages: django-polls
Running setup.py bdist_wheel for django-polls ... done
Stored in directory: /home/viet/.cache/pip/wheels/ff/ec/8b/85c031efa2ba719d6bd909d20f61ca6b106c79345a1e875f08
Successfully built django-polls
Then the tutorial says:
With luck, your Django project should now work correctly again. Run
the server again to confirm this.
How? There's no manage.py file in /django-polls or in /home/viet/.cache/pip/wheels/ff/ec/8b/85c031efa2ba719d6bd909d20f61ca6b106c79345a1e875f08
So I tried this:
$ pip3 uninstall django-polls
Uninstalling django-polls-0.1:
...
Proceed (y/n)? y
Successfully uninstalled django-polls-0.1
$ pip3 install --user django-polls/dist/django-polls-0.1.tar.gz
Processing ./django-polls/dist/django-polls-0.1.tar.gz
Building wheels for collected packages: django-polls
Running setup.py bdist_wheel for django-polls ... done
Stored in directory: /home/viet/.cache/pip/wheels/ff/ec/8b/85c031efa2ba719d6bd909d20f61ca6b106c79345a1e875f08
Successfully built django-polls
Installing collected packages: django-polls
Successfully installed django-polls-0.1
I'm lost at this point.
Update:
Thank you for your suggestions, I understand now that I need to move the folder /polls out of my folder /mysite into the folder /django-polls
So the tree looks like this:
~/webdev$ ls -a
django-polls mysite
$ cd django-polls/
s$ ls -a
. dist docs MANIFEST.in README.rst
.. django_polls.egg-info LICENSE polls setup.py
I ran in /webdev:
$ pip3 install --user django-polls/dist/django-polls-0.1.tar.gz
Processing ./django-polls/dist/django-polls-0.1.tar.gz
...
Successfully built django-polls
$ cd mysite/
$ python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
No migrations to apply.
$ python3 manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
April 09, 2018 - 09:29:25
Django version 2.0.3, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
I go to localhost:8000/polls:
Internal Server Error: /polls/
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 158, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 156, in _get_response
response = response.render()
File "/usr/local/lib/python3.6/dist-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/usr/local/lib/python3.6/dist-packages/django/template/response.py", line 81, in rendered_content
template = self.resolve_template(self.template_name)
File "/usr/local/lib/python3.6/dist-packages/django/template/response.py", line 63, in resolve_template
return select_template(template, using=self.using)
File "/usr/local/lib/python3.6/dist-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: polls/index.html, polls/question_list.html
[09/Apr/2018 09:29:28] "GET /polls/ HTTP/1.1" 500 83106
I just copied the whole /polls to /django-polls and the built was successful, why I have the error that TemplateDoesNotExist while the /polls worked just fine inside /mysite?
Update 2018-04-30
New error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
It ran fine before and I've tried starting the server in a virtual environment but the app doesn't recognise the installed Django.
Step number 2 in the packaging your app section of the tutorial instructs to move polls app out from the project directory to django-polls.
If at this point you run development server, django will throw an exception since polls is listed in installed apps but does not exist in any path visible to python.
When you install the package, pip installs the django-polls package in site-packages directory of your python installation.
At this point, running migrate, should use the polls app from site-packages.
1) For the first part of your question: I missunderstood, sorry. #Paulo and #Vishal already explained very well.
2) For the second part: you've installed django-polls app successfully, so
your server runs and finds polls app, but cannot find 'polls/index.html' template. That is why you see the error below:
TemplateDoesNotExist: polls/index.html, polls/question_list.html
You should check wether the template files are in the right place or not.
The templates are located in path_to_virtualenv\Lib\site-packages\polls\templates\polls directory if you installed django-polls app within a virtual environment. Otherwise (system-wide install), you can look in python_path\Lib\site-packages\polls\templates\polls
You might have already solved the problem until now, sorry for answering lately due to some reasons. I hope it helps.
Here is my case hit the error:
django.template.exceptions.TemplateDoesNotExist: polls/index.html, polls/question_list.html
I follow this guide: https://docs.djangoproject.com/en/2.2/intro/reusable-apps/
And, I am using the virtualenv.
Here is my folder structure:
(venv) ☁ mrdulin tree -L 1 | grep 'django'
├── django-codelab
├── django-polls
The error caused by the file name of MANIFEST.in file. I copy the file name from guide. But somehow, there is a empty space at the beginning of the file name. Which means the file name is
When I run python setup.py sdist command, the output like this:
(venv) ☁ django-codelab [master] ⚡ ..
(venv) ☁ mrdulin cd django-polls
(venv) ☁ django-polls python setup.py sdist
running sdist
running egg_info
creating django_polls.egg-info
writing django_polls.egg-info/PKG-INFO
writing dependency_links to django_polls.egg-info/dependency_links.txt
writing top-level names to django_polls.egg-info/top_level.txt
writing manifest file 'django_polls.egg-info/SOURCES.txt'
reading manifest file 'django_polls.egg-info/SOURCES.txt'
writing manifest file 'django_polls.egg-info/SOURCES.txt'
running check
creating django-polls-0.1
creating django-polls-0.1/django_polls.egg-info
creating django-polls-0.1/polls
creating django-polls-0.1/polls/migrations
copying files to django-polls-0.1...
copying README.rst -> django-polls-0.1
copying setup.cfg -> django-polls-0.1
copying setup.py -> django-polls-0.1
copying django_polls.egg-info/PKG-INFO -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/SOURCES.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/dependency_links.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/top_level.txt -> django-polls-0.1/django_polls.egg-info
copying polls/__init__.py -> django-polls-0.1/polls
copying polls/admin.py -> django-polls-0.1/polls
copying polls/apps.py -> django-polls-0.1/polls
copying polls/models.py -> django-polls-0.1/polls
copying polls/tests.py -> django-polls-0.1/polls
copying polls/urls.py -> django-polls-0.1/polls
copying polls/views.py -> django-polls-0.1/polls
copying polls/views_old.py -> django-polls-0.1/polls
copying polls/migrations/0001_initial.py -> django-polls-0.1/polls/migrations
copying polls/migrations/__init__.py -> django-polls-0.1/polls/migrations
Writing django-polls-0.1/setup.cfg
creating dist
Creating tar archive
removing 'django-polls-0.1' (and everything under it)
As you can see, the files in templates, static, docs directory are no copied to dist directory. This is the reason.
After I remove the empty space from file name of MANIFEST.in file, run python setup.py sdist command again, the output is:
(venv) ☁ django-polls python setup.py sdist
running sdist
running egg_info
creating django_polls.egg-info
writing django_polls.egg-info/PKG-INFO
writing dependency_links to django_polls.egg-info/dependency_links.txt
writing top-level names to django_polls.egg-info/top_level.txt
writing manifest file 'django_polls.egg-info/SOURCES.txt'
reading manifest file 'django_polls.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'django_polls.egg-info/SOURCES.txt'
running check
creating django-polls-0.1
creating django-polls-0.1/django_polls.egg-info
creating django-polls-0.1/docs
creating django-polls-0.1/polls
creating django-polls-0.1/polls/migrations
creating django-polls-0.1/polls/static
creating django-polls-0.1/polls/static/polls
creating django-polls-0.1/polls/static/polls/images
creating django-polls-0.1/polls/templates
creating django-polls-0.1/polls/templates/polls
copying files to django-polls-0.1...
copying LICENSE -> django-polls-0.1
copying MANIFEST.in -> django-polls-0.1
copying README.rst -> django-polls-0.1
copying setup.cfg -> django-polls-0.1
copying setup.py -> django-polls-0.1
copying django_polls.egg-info/PKG-INFO -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/SOURCES.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/dependency_links.txt -> django-polls-0.1/django_polls.egg-info
copying django_polls.egg-info/top_level.txt -> django-polls-0.1/django_polls.egg-info
copying docs/.gitkeep -> django-polls-0.1/docs
copying polls/__init__.py -> django-polls-0.1/polls
copying polls/admin.py -> django-polls-0.1/polls
copying polls/apps.py -> django-polls-0.1/polls
copying polls/models.py -> django-polls-0.1/polls
copying polls/tests.py -> django-polls-0.1/polls
copying polls/urls.py -> django-polls-0.1/polls
copying polls/views.py -> django-polls-0.1/polls
copying polls/views_old.py -> django-polls-0.1/polls
copying polls/migrations/0001_initial.py -> django-polls-0.1/polls/migrations
copying polls/migrations/__init__.py -> django-polls-0.1/polls/migrations
copying polls/static/polls/style.css -> django-polls-0.1/polls/static/polls
copying polls/static/polls/images/background.jpg -> django-polls-0.1/polls/static/polls/images
copying polls/templates/polls/detail.html -> django-polls-0.1/polls/templates/polls
copying polls/templates/polls/index.html -> django-polls-0.1/polls/templates/polls
copying polls/templates/polls/results.html -> django-polls-0.1/polls/templates/polls
Writing django-polls-0.1/setup.cfg
creating dist
Creating tar archive
removing 'django-polls-0.1' (and everything under it)
(venv) ☁ django-polls
Now, the files in template, static, docs directory are copied to dist directory.
Then, change directory to django-codelab, run below command:
pip3 install ../django-polls/dist/django-polls-0.1.tar.gz
Add polls application into INSTALLED_APPS list:
INSTALLED_APPS = [
'polls',
# 'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Run the server:
python manage.py runserver
It works perfectly! So, the tutorial is correct. Please check your steps and be careful with coding
You should verify that the
django-polls
was successfully installed base on the command you fired up
pip install --user django-polls/dist/django-polls-0.1.tar.gz
I'm on windows and it will install inside if successfull
C:\Users\{username}\AppData\Roaming\Python\Python37\site-packages
-->django_polls-0.1-py3.7.egg-info
-->polls
if you only see
-->django_polls-0.1-py3.7.egg-info
then you should double check your setup.cfg if you write it correctly including the indents then run python setup.py sdist again
if all are correct then run the server just like before (manage.py) inside the project where you pulled out polls directory (the same project you used before)
D:\websiteprojects\djangotutorial01\mysite>python manage.py runserver
(remember) polls folder is no longer inside that
D:\websiteprojects\djangotutorial01\mysite>
but it still will run because it was successfully installed inside
C:\Users\{username}\AppData\Roaming\Python\Python37\site-packages
I've got a folder called Packages in my home folder. In this folder I want to develop some packages. To test them I tried to install the package with
python setup.py install develop
while inside the environment, of course. This gives me the following output
develop
running install
running bdist_egg
running egg_info
writing BACnetScapy.egg-info/PKG-INFO
writing top-level names to BACnetScapy.egg-info/top_level.txt
writing dependency_links to BACnetScapy.egg-info/dependency_links.txt
reading manifest file 'BACnetScapy.egg-info/SOURCES.txt'
writing manifest file 'BACnetScapy.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/BACnetScapy
copying build/lib.linux-x86_64-2.7/BACnetScapy/BACnetLayers.py -> build/bdist.linux-x86_64/egg/BACnetScapy
copying build/lib.linux-x86_64-2.7/BACnetScapy/BACnetTags.py -> build/bdist.linux-x86_64/egg/BACnetScapy
copying build/lib.linux-x86_64-2.7/BACnetScapy/__init__.py -> build/bdist.linux-x86_64/egg/BACnetScapy
copying build/lib.linux-x86_64-2.7/BACnetScapy/BACnetFunctions.py -> build/bdist.linux-x86_64/egg/BACnetScapy
copying build/lib.linux-x86_64-2.7/BACnetScapy/BACnetConstants.py -> build/bdist.linux-x86_64/egg/BACnetScapy
byte-compiling build/bdist.linux-x86_64/egg/BACnetScapy/BACnetLayers.py to BACnetLayers.pyc
byte-compiling build/bdist.linux-x86_64/egg/BACnetScapy/BACnetTags.py to BACnetTags.pyc
byte-compiling build/bdist.linux-x86_64/egg/BACnetScapy/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/BACnetScapy/BACnetFunctions.py to BACnetFunctions.pyc
byte-compiling build/bdist.linux-x86_64/egg/BACnetScapy/BACnetConstants.py to BACnetConstants.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying BACnetScapy.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying BACnetScapy.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying BACnetScapy.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying BACnetScapy.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/BACnetScapy-1.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing BACnetScapy-1.0-py2.7.egg
Copying BACnetScapy-1.0-py2.7.egg to /home/lk/virtualenvs/FuzzingEnv/lib/python2.7/site-packages
Adding BACnetScapy 1.0 to easy-install.pth file
Installed /home/lk/virtualenvs/FuzzingEnv/lib/python2.7/site-packages/BACnetScapy-1.0-py2.7.egg
Processing dependencies for BACnetScapy==1.0
Finished processing dependencies for BACnetScapy==1.0
running develop
Checking .pth file support in build/bdist.linux-x86_64/egg
/home/lk/virtualenvs/FuzzingEnv/bin/python -E -c pass
TEST FAILED: build/bdist.linux-x86_64/egg does NOT support .pth files
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
build/bdist.linux-x86_64/egg
and your PYTHONPATH environment variable currently contains:
''
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
So the problem seems to be that the build folder which is automatically created in the package folder is not on the PYTHONPATH - but why should it be? And how should I add it to the PYTHONPATH? I tried to add this folder with
add2virtualenv /home/lk/Packages/BACnetScapy/build
but that did not work, either.
What am I doing wrong?
This is my setup.py
from setuptools import setup
setup(
name="BACnetScapy",
author="lk",
version="1.0",
packages=["BACnetScapy"],
include_package_data=True
)
The folder looks like that
/BACnetScapy
|
|-/BACnetScapy
| |- some.py
| |- modules.py
| |- __init__.py
| |-/data # a folder containing some data the package needs
|
|-setup.py
The command should be python setup.py develop, not python setup.py install develop