i am working on a long project in Django and suddenly i faced this error:
import asyncio
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\asyncio\__init__.py", line 17, in <module>
from .streams import *
ModuleNotFoundError: No module named 'asyncio.streams'
I tried to instal it using : pip install asyncio, But again it gave some errors :
Traceback (most recent call last):
File "c:\users\appdata\local\programs\python\python38\lib\shutil.py", line 587, in _rmtree_unsafe
with os.scandir(path) as scandir_it:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\AppData\\Local\\Temp\\pip-req-tracker-ua43f6rj'
please Tell me how can i fix it . I am Using Python 3.8.1
Please reinstall python3.8.1 for windows 10
Packages and modules in python can be imported when they appear in the PYTHONPATH environement variable or in the sys.path list.
On each PYTHONPATH expanding, will ends up in the sys.path list.
so make sure that, the instalation of your asyncio was successeful and its path exist in the sys.path list. how you check? see below:
in comand line or in script.py type:
import sys
p_asyn=r'C:\Users\AppData\Local\Programs\Python\Python38\lib\asyncio'
if p_asyn not in sys.path:
print('asyncio not in the sys path list! :-(')
sys.path.append(p_asyn)
its better to append new paths to the PYTHONPATH rather than editing the sys.path.
Anywa, if the module you are trying to import (asuncio) is a built in lib/module you should check if the pyhton installation was successful and the path environement variable edited correctly and has all paths that should be.
in windows make sure that python installation dir appears in the path. if not use the set command,
set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
Python usually stores its library (and thereby your site-packages folder) in the installation directory. So, if you had installed Python to C:\Python\, the default library would reside in C:\Python\Lib\ and third-party modules should be stored in C:\Python\Lib\site-packages.
This attended to windows users.
for further reading, enter the link here
using_py2
using_py3
Related
I know there has been similar problems, but unfortunately most of them are related to errors with pyperclip itself instead of the batch file, which i suspect is where the problem stems from.
Below is an MRE of my Python script:
#! python3 -> Do I have to use my version(3.8)?
# pw.py - An insecure password locker program.
import sys, pyperclip
#do something with the module
And my batch file pw.bat:
#py.exe C:\Users\KEVIN\PycharmProjects\atbs_exercise\pw.py %*
#pause
I am running python 3.8 on windows 10. I imported the pyperclip module in my python script pw.py and ran the file via pw.bat, and this in turn gives me this error:
Traceback (most recent call last):
File "C:\Users\KEVIN\PycharmProjects\atbs_exercise\pw.py", line 7, in <module>
import sys, pyperclip
ModuleNotFoundError: No module named 'pyperclip'
Press any key to continue . . .
Which shouldn't happen as I have installed pyperclip on the project using pip, and the script itself runs just fine in pycharm. What am I missing?
EDIT: I forgot to mention that I am using pycharm. So the thing is that pycharm had also installed python.exe in the project folder. And as the module pyperclip is only installed to that folder, the python.exe used in the bat must point to the one in the project folder.
i don't know why are you using py.exe. when running commands from a batch file or cmd .you should use python.exe.obviously you would need to add python to add for doing so.instead of adding py.exe to path,add python in system variable Path which is somewhere present in C:\Users\[username]\AppData\Local\Programs\Python\(your path might be diffrernt).you can add python in Path by following this post
after adding python to path just use the following batch-file:
#echo off
python path-to-your-py-file\filename.py
after a computer fix my python projects dir (windows) changed (say from d: to f:).
now all my virtualenvs are broken. after activating the env the project inside the virtualenv can't find the dependencies and the custom scripts (from the env\scripts folder)won't work
tried running:
virtualenv --relocateble ENV_NAME (with the env name ..)
like in this stackoverflow question and it outputted a lot of lines like:
Script agent\Scripts\deactivate.bat cannot be made relative
and my virtualenv is still broken.
when I manually changed activate.bat set VIRTUAL_ENV to the new path. some scripts work again. but the relocate scripts still doesn't run and most of the scripts are still broken
even running the python interpeter fails with:
Traceback (most recent call last):
File "F:\Python27\learn\agent\agent\lib\site.py", line 677, in <module>
main()
File "F:\Python27\learn\agent\agent\lib\site.py", line 666, in main
aliasmbcs()
File "F:\Python27\learn\agent\agent\lib\site.py", line 506, in aliasmbcs
import locale, codecs
File "F:\Python27\learn\agent\agent\lib\locale.py", line 19, in <module>
import functools
ImportError: No module named functools
is there any way to fix this? HELP
Update: I also changed manually the shebang python interpeter line in all scripts in ENV\Scripts. now all fail with the same python failure as above
Another Update: to #udi the system python path is:
['', 'C:\\dev\\Python27\\lib\\site-packages\\distribute-0.6.37-py2.7.egg', 'C:\\
dev\\Python27\\lib\\site-packages\\pip-1.3.1-py2.7.egg', 'C:\\dev\\Python27\\lib
\\site-packages\\numpy-1.7.1-py2.7-win32.egg', 'C:\\dev\\Python27\\lib\\site-pac
kages\\pandas-0.11.0-py2.7-win32.egg', 'C:\\dev\\Python27\\lib\\site-packages\\p
ytz-2013b-py2.7.egg', 'C:\\dev\\Python27\\lib\\site-packages\\python_dateutil-2.
1-py2.7.egg', 'C:\\dev\\Python27\\lib\\site-packages\\six-1.3.0-py2.7.egg', 'C:\
\dev\\Python27\\lib\\site-packages\\tornado-3.0.1-py2.7.egg', 'C:\\dev\\Python27
\\lib\\site-packages\\pyzmq-13.1.0-py2.7-win32.egg', 'C:\\dev\\Python27\\lib\\si
te-packages\\pygments-1.6-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'C:
\\dev\\Python27\\DLLs', 'C:\\dev\\Python27\\lib', 'C:\\dev\\Python27\\lib\\plat-
win', 'C:\\dev\\Python27\\lib\\lib-tk', 'C:\\dev\\Python27', 'C:\\dev\\Python27\
\lib\\site-packages', 'C:\\dev\\Python27\\lib\\site-packages\\setuptools-0.6c11-
py2.7.egg-info']
since I can't run python from the virtualenv, I can't print the python path from there
Correcting python directory path in ENV_FOLDER\Lib\orig-prefix.txt helped me
Seems like your system and local environments create a mix of libraries and binaries from different versions of python.
Chances are you would need to delete Lib, Scripts and Include and start again with virtualenv .. You might be able to save the site-packages folder, but if you have requirements.txt files, you should probably reinstall packages instead (see also: How do I install from a local cache with pip? ).
Anyway, I believe you can create a script that does all this in one step.
I installed both py2 and py3 on my windows 10. And got this error by create virtualenv by using virtualenv xxx directly. After purging folder xxx and reinstalling with virtualenv -p TARGET_PY_EXE xxx everything works smoothly.
Hope this will help multiple python windows users.
By the way, I simply create env variables as PY2 and PY3 instead of adding absolute paths into PATH.
i did a virtualenv in c:\users\devtool.virtualenv\devenv
After i run activate.bat.
And last i wrote a simple py file to test environment:
import os,sys
for x in sys.path:
print x
print os.executable
and result is weird
C:\Users\devtool\.virtualenv\devenv\Scripts
C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg
C:\Python27\lib\site-packages\virtualenv-1.8.4-py2.7.egg
C:\Python27\lib\site-packages\pip-1.2.1-py2.7.egg
C:\Users\developer\.virtualenv\devenv\Lib\site-packages\django
C:\Windows\system32\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
['C:\\Users\\developer\\.virtualenv\\devenv\\Lib\\site-packages\\django']
C:\Python27\python.exe
in fact it is just using base python install.
What is the point of using virtualenv?
i am getting errors with django, installed in virtualenv.
i can solve it, just need to rewrite django-admin.py to append to search path my virtualenv folder, but still what is need of virtualenv in this case.
another thing that i cant understand. In the python search path, there is a line
C:\Users\devtools\.virtualenv\devenv\Lib\site-packages\django
and when i use django-admin.py i get
Traceback (most recent call last):
File "C:\Users\devtools\.virtualenv\devenv\Scripts\django-admin.py", line 12, in module>
from django.core import management
ImportError: No module named django.core
but django folder is in the path
I have also faced the same issue few days before. From the base folder, you have to execute the following command.
C:\Users\devtools\.virtualenv\devenv> python Scripts\django-admin.py startproject myproj
virtualenv extends/overrides your system python environment with its paths prepended to the paths of the system python installation. You see, you .virtualenv site-packages are listed before the system site-packages, that's how it works.
The thing you have to keep in mind that activate patches your current command line environment, so you must run activate before running python code depending on your virtualenv.
This Drives me nuts...
I use the latest EPD Distribution on the latest Mac and I want to study the book "Python for software design". Therein, Chap. 4, is one should load to play around with.
But to do that I seemingly need to set a PATH variable to the relevant directory. As I am not very familiar I looked around and finally added this to my .bash-profile:
"PYTHONPATH="$HOME/Dropbox/Programming/swampy-2.0"
The check with the Terminal:
Andreass-Mac-mini:~ ak$ $PYTHONPATH
-bash: /Users/ak/Dropbox/Programming/swampy-2.0: is a directory
Up to this point I would say it should work. And then comes this:
>>> from TurtleWorld import *
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from TurtleWorld import *
ImportError: No module named TurtleWorld
It is the right file name, the correct directory and it seems to me that the path is not right?
So what do I have to do/change that it works on my Mac?
Edit: and by the way - (on a different) I also created a directory .MacOSX and put the file environment.plist therein with the same path variable. Nothing changed :-(
Thanks
Andreas
Use the export command in your .bash-profile to make environment variables appear in other contexts:
export PYTHONPATH=$HOME/Dropbox/Programming/swampy-2.0
Did you name your script Turtleworld.py? If so, that is the issue. The module can't be imported if your script name is the same as the module name. Hope this helps! :D
I successfully built and installed VTK-5.4 with Python bindings from source. Yet, when I try to import VTK in python it gives the following Traceback error
File "", line 1, in
File "/usr/local/lib/python2.6/dist-packages/VTK-5.4.2-py2.6.egg/vtk/init.py",
line 41, in from common import *
File "/usr/local/lib/python2.6/dist-packages/VTK-5.4.2-py2.6.egg/vtk/common.py",
line 7, in from libvtkCommonPython import *
ImportError:
libvtkCommonPythonD.so.5.4: cannot open shared object file: No such file or directory
So I am wondering what I am missing? I have tried adding /usr/local/lib/vtk-5.4 to both PATH and PYTHONPATH environment variables and still get the same result. Any hints or suggestions?
NOTE:
libvtkCommonPythonD.so.5.4 exists in /usr/local/lib/vtk-5.4 as a symlink to libvtkCommonPythonD.so.5.4.2
Test if adding /usr/local/lib to your $LD_LIBRARY_PATH helps:
In a shell:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
If it works, make it permanent by (adding /usr/local/lib to /etc/ld.so.conf) _ (running 'ldconfig -n /usr/local/lib')